package com.spring.boot.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.spring.boot.entity.Role;
import org.apache.ibatis.annotations.Select;

/**
 * @author 刘骄阳
 * 2021-07-16 9:55
 */
public interface RoleDao extends BaseMapper<Role> {
    /**
     * 获取指定用户的角色信息
     *
     * @param id 用户Id
     * @return 角色信息
     */
    @Select("SELECT " +
            " r.id, " +
            " r.`name` " +
            " FROM " +
            " user_role ur " +
            " LEFT JOIN role r ON r.id = ur.role_id " +
            " LEFT JOIN users u ON u.id = ur.user_id " +
            " WHERE " +
            " ur.user_id =#{id} ")
    Role checkRole(Integer id);
}
